
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:i18n_demo/Localizations/localizations.dart';

class JKLocalizationsDelegate extends LocalizationsDelegate<JKLocalizations> {
  @override
  bool isSupported(Locale locale) {
    return ["en", "zh"].contains(locale.languageCode);
  }

  @override
  bool shouldReload(LocalizationsDelegate<JKLocalizations> old) {
    return false;
  }

  @override
  Future<JKLocalizations> load(Locale locale) async {
    final localization = JKLocalizations(locale);
    await localization.loadJson();
    return localization;
  }

  static JKLocalizationsDelegate delegate = JKLocalizationsDelegate();
}